home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-09 | 6.2 KB | 168 lines | [TEXT/R*ch] |
- // ===========================================================================
- // File: CIncludeView.cp
- // Version: 1.0 - Feb 1, 1996
- // Author: Mike Shields (mshields@inconnect.com)
- //
- // Copyright ©1996 Mike Shields. All rights reserved.
- // I hereby grant users of CIncludeView permission to use it (or any modified
- // version of it) in applications (or any other type of Macintosh software
- // like extensions -- freeware, shareware, commercial, or other) for free,
- // subject to the terms that:
- //
- // (1) This agreement is non-exclusive.
- //
- // (2) I, Mike Shields, retain the copyright to the original source code.
- //
- // These two items are the only required conditions for use. However, I do have
- // an additional request. Note, however, that this is only a request, and
- // that it is not a required condition for use of this code.
- //
- // (1) That I be given credit for CIncludeView code in the copyrights or
- // acknowledgements section of your manual or other appropriate documentation.
- //
- //
- // I would like to repeat that this last item is only a request. You are prefectly
- // free to choose not to do any or all of them.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // ===========================================================================
- // CIncludeView.h <- double-click + Command-D to see class declaration
- //
- // Class which controls the loading and disposing of a subpane.
-
- #include "CIncludeView.h"
-
- #include <PP_Constants.h>
- #include <LStream.h>
- #include <UDrawingState.h>
- #include <UReanimator.h>
-
- #pragma mark === Construction & Destruction ===
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::CreateFromStream
- //----------------------------------------------------------------------------------------
- // Static function registered with URegistrar to create a IncludeView from the data in a stream
- CIncludeView* CIncludeView::CreateFromStream(LStream *inStream)
- {
- return (new CIncludeView(inStream));
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::CIncludeView
- //----------------------------------------------------------------------------------------
- // Default constructor
- CIncludeView::CIncludeView()
- : mCurrentIncludedPane(nil), mPaneID(PaneIDT_Undefined)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::CIncludeView
- //----------------------------------------------------------------------------------------
- // Does shallow copy; SubPanes are not copied.
- CIncludeView::CIncludeView(const CIncludeView &inOriginal)
- : LView(inOriginal), mCurrentIncludedPane(nil)
- {
- mPaneID = inOriginal.mPaneID;
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::CIncludeView
- //----------------------------------------------------------------------------------------
- // create an IncludeView from the passed in data
- CIncludeView::CIncludeView(const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo,
- ResIDT inStartingPane)
- : LView(inPaneInfo, inViewInfo), mCurrentIncludedPane(nil)
- {
- mPaneID = inStartingPane;
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::CIncludeView
- //----------------------------------------------------------------------------------------
- // create an IncludeView from the data in the stream
- CIncludeView::CIncludeView(LStream *inStream)
- : LView(inStream), mCurrentIncludedPane(nil)
- {
- inStream->ReadData(&mPaneID, sizeof(ResIDT));
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::~CIncludeView
- //----------------------------------------------------------------------------------------
- // Destructor
- CIncludeView::~CIncludeView()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::FinishCreateSelf
- //----------------------------------------------------------------------------------------
- // When the creation process is compelete, we need to read in the view we've been asked to
- // include initially. We do this now because everything has settled down from the creation
- // process and everything else is fully constructed.
- void CIncludeView::FinishCreateSelf()
- {
- if ( mPaneID != PaneIDT_Undefined )
- {
- LoadSubPane();
- }
- }
-
- #pragma mark === Subview creation/deletion ===
- //----------------------------------------------------------------------------------------
- // CIncludeView::IncludeView
- //----------------------------------------------------------------------------------------
- // This function is called when a pane is to be read in from a PPob resource and added as
- // this view's subview.
- void CIncludeView::IncludeView(ResIDT inPaneID, Boolean inRefresh)
- {
- if ( mCurrentIncludedPane != nil )
- {
- DisposeSubPane();
- }
-
- // Prevent List and Control Managers from automatically drawing by setting
- // an empty clipping region
- StClipRgnState saveClip(nil);
-
- mPaneID = inPaneID;
- LoadSubPane();
-
- if ( inRefresh )
- {
- Refresh();
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::DisposeSubPane
- //----------------------------------------------------------------------------------------
- // remove the subpane from our subpane list and free it.
- void CIncludeView::DisposeSubPane()
- {
- delete mCurrentIncludedPane;
-
- mCurrentIncludedPane = nil;
- mPaneID = PaneIDT_Undefined;
- }
-
- //----------------------------------------------------------------------------------------
- // CIncludeView::LoadSubPane
- //----------------------------------------------------------------------------------------
- // Load in a subpane from a a PPob resource, add it to our subpane list and initialize it
- // as if it was being read in at window creation time
- void CIncludeView::LoadSubPane()
- {
- LView *defaultView = LPane::GetDefaultView();
-
- LPane::SetDefaultView(this);
- mCurrentIncludedPane = (LPane*)UReanimator::ReadObjects('PPob', mPaneID);
- LPane::SetDefaultView(defaultView);
-
- mCurrentIncludedPane->FinishCreate();
- }
-